package com.holyant.goods.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDto;
import com.ruoyi.common.utils.bean.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 商品调价申请dto
 *
 * @author g
 * @date 2022-02-09
 */
@Data
@ApiModel("商品调价申请")
public class GdsSkuQuoteHistoryDto extends BaseDto {

    private static final long serialVersionUID = 1L;

    /**
     * 编码
     */
    @Excel(name = "编码")
    @ApiModelProperty(value = "编码")
    private String code;
    /**
     * 报价类型(10成本价20结算价)
     */
    @Excel(name = "报价类型(10成本价20结算价)")
    @ApiModelProperty(value = "报价类型(10成本价20结算价)")
    private Integer quoteType;
    /** 店铺id */
    @ApiModelProperty(name = "店铺id")
    private Long shopId;
    /** 店铺名称 */
    @ApiModelProperty(name = "店铺名称")
    private String shopName;
    /** 客户id */
    @ApiModelProperty(name = "客户id")
    private Long customerId;
    /** 客户名称 */
    @ApiModelProperty(name = "客户名称")
    private String customerName;
    /**
     * 平台
     */
    private String platform;
    /**
     * 企业id
     */
    @Excel(name = "企业id")
    @ApiModelProperty(value = "企业id")
    private Long enterpriseId;
    /**
     * 企业名称
     */
    @Excel(name = "企业名称")
    @ApiModelProperty(value = "企业名称")
    private String enterpriseName;
    /**
     * 渠道
     */
    @Excel(name = "渠道")
    @ApiModelProperty(value = "渠道")
    private Integer salesChannel;
    /**
     * 申请时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "申请时间")
    private LocalDateTime applyTime;
    /**
     * 有效时间开始
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "有效时间开始", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "有效时间开始")
    private LocalDate effectiveTimeStart;
    /**
     * 有效时间结束
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "有效时间结束", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "有效时间结束")
    private LocalDate effectiveTimeEnd;
    /**
     * 描述
     */
    @Excel(name = "描述")
    @ApiModelProperty(value = "描述")
    private String remark;

    private Long itemId;

    /** 报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税 */
    @Excel(name = "报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税")
    @ApiModelProperty(value = "报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税")
    private Integer quoteMethod;
    /** skuid */
    @Excel(name = "skuid")
    @ApiModelProperty(value = "skuid")
    private Long skuId;
    /** sku编码 */
    @Excel(name = "sku编码")
    @ApiModelProperty(value = "sku编码")
    private String skuCode;
    /** 商品id */
    @Excel(name = "商品id")
    @ApiModelProperty(value = "商品id")
    private Long goodsId;
    /** 商品名称 */
    @Excel(name = "商品名称")
    @ApiModelProperty(value = "商品名称")
    private String goodsName;
    /** 商品条码 */
    @Excel(name = "商品条码")
    @ApiModelProperty(value = "商品条码")
    private String goodsBarcode;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "失效日期", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "失效日期")
    private LocalDate expireDate;
    /** 分类id */
    @Excel(name = "分类id")
    @ApiModelProperty(value = "分类id")
    private Long categoryId;
    /** 分类编码 */
    @Excel(name = "分类编码")
    @ApiModelProperty(value = "分类编码")
    private String categoryCode;
    /** 分类名称 */
    @Excel(name = "分类名称")
    @ApiModelProperty(value = "分类名称")
    private String categoryName;
    /** 计量单位id */
    @Excel(name = "计量单位id")
    @ApiModelProperty(value = "计量单位id")
    private Long unitId;
    /** 计量单位名称 */
    @Excel(name = "计量单位名称")
    @ApiModelProperty(value = "计量单位名称")
    private String unitName;
    /** 毛重 */
    @Excel(name = "毛重")
    @ApiModelProperty(value = "毛重")
    private BigDecimal grossWeigtht;
    /** 净重 */
    @Excel(name = "净重")
    @ApiModelProperty(value = "净重")
    private BigDecimal netWeigtht;
    /** 体积 */
    @Excel(name = "体积")
    @ApiModelProperty(value = "体积")
    private BigDecimal volume;
    /** 规格 */
    @Excel(name = "规格")
    @ApiModelProperty(value = "规格")
    private String specs;
    /** 箱规 */
    @Excel(name = "箱规")
    @ApiModelProperty(value = "箱规")
    private String boxSpec;
    /** 托规 */
    @Excel(name = "托规")
    @ApiModelProperty(value = "托规")
    private String palletSpec;
    @Excel(name = "品牌")
    @ApiModelProperty(value = "品牌")
    private String goodsExtAttr;
    /** 品牌id */
    @Excel(name = "品牌id")
    @ApiModelProperty(value = "品牌id")
    private Long brandId;
    /** 品牌名称 */
    @Excel(name = "品牌名称")
    @ApiModelProperty(value = "品牌名称")
    private String brandName;
    /** 币种 */
    @Excel(name = "币种")
    @ApiModelProperty(value = "币种")
    private Integer curType;
    /** 价格 */
    @Excel(name = "价格")
    @ApiModelProperty(value = "价格")
    private String priceObj;

    /** 审核人id */
    @ApiModelProperty(value = "审核人id")
    private Long auditById;
    /** 审核人名称 */
    @ApiModelProperty(value = "审核人名称")
    private String auditByName;
    /** 审核时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "审核时间")
    private LocalDateTime auditTime;


    public JSONObject getSpecsPrice() {
        if (Objects.nonNull(priceObj)) {
            return JSON.parseObject(priceObj);
        }
        return new JSONObject();
    }



    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        GdsSkuQuoteHistoryDto that = (GdsSkuQuoteHistoryDto) o;
        return Objects.equals(enterpriseId, that.enterpriseId) &&
                Objects.equals(salesChannel, that.salesChannel) &&
                Objects.equals(quoteMethod, that.quoteMethod) &&
                Objects.equals(quoteType, that.quoteType) &&
                Objects.equals(effectiveTimeStart, that.effectiveTimeStart) &&
                Objects.equals(skuId, that.skuId) &&
                Objects.equals(curType, that.curType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(enterpriseId, salesChannel, quoteMethod,quoteType,effectiveTimeStart, skuId, curType);
    }



    public GdsSkuPriceDto convertSkuPriceDto(){
        GdsSkuPriceDto gdsSkuPriceDto = new GdsSkuPriceDto();
        BeanUtils.copyBeanProp(this,gdsSkuPriceDto);
        gdsSkuPriceDto.setEffectiveDate(this.getEffectiveTimeStart());
        return gdsSkuPriceDto;
    }

}
